/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.SmsTempletMapper;
import com.ybkj.daijia.server.model.SmsTemplet;
import com.ybkj.daijia.server.model.SmsTemplet.SmsType;
import com.ybkj.daijia.server.service.SmsTempletService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultSmsTempletService implements SmsTempletService {

    @Autowired
    private SmsTempletMapper smsTempletMapper;

    public List<SmsTemplet> listAll() {

//		Subject currentUser = SecurityUtils.getSubject();
//		Principal principal = (Principal) currentUser.getPrincipal();

        return smsTempletMapper.selectAll();
    }

    @Override
    public List<SmsTemplet> listByCompany(Long companyId) {

        return smsTempletMapper.selectByCompany(companyId);

    }

    @Transactional(rollbackFor = Exception.class)
    public SmsTemplet insertSmsTemplate(SmsTemplet smsTemplet) {

        smsTempletMapper.insertRecord(smsTemplet);

        return smsTemplet;
    }

    @Override
    public SmsTemplet findOne(Long id) {

        return smsTempletMapper.selectByPrimaryKey(id);
    }

    @Override
    public SmsTemplet findByCompanyAndType(Long companyId, SmsType smsType) {

        return smsTempletMapper.selectByCompanyAndType(companyId, smsType);

    }

    @Override
    public SmsTemplet findBySmsType(SmsType type) {

        return smsTempletMapper.selectBySmsType(type);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateByPrimaryKey(SmsTemplet smsTemplet) {
        return smsTempletMapper.updateByPrimaryKey(smsTemplet);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchUpdateByPrimaryKey(List<SmsTemplet> records) {
        return smsTempletMapper.batchUpdateByPrimaryKey(records);
    }


}